10  ' circlock.bas - FREEWARE
20 GOTO 130 ' begin
30 SAVE "circlock.bas",A:LIST-130
40 GOTO 500 ' display at start up
50 GOTO 510 ' display cont
60 GOTO 570 ' print@ to locate
70 GOTO 590 ' delay 1/9 seconds
80 GOTO 610 ' change display subroutines
90 GOTO 660 ' change display 2
100 GOTO 710 ' init F1
110 GOTO 750 ' get key
120 ' begin 
130 CLS:KEY OFF:L=40:SCREEN 1:GOSUB 100
140 DEFSTR Q:Q=MKI$(0)
150 PRINT "Circles Digital Clock":PRINT:PRINT:PRINT "    Press to start"
160 ' initialize
170 DIM B(9,23),S(3,15),T(9,15):C=79
180 FOR N=0 TO 9:FOR EQ=1 TO 12:READ BN:B(N,BN)=1:NEXT:NEXT
190 FOR N=0 TO 9:FOR EQ=0 TO 15:READ T(N,EQ):NEXT:NEXT
200 FOR N=0 TO 3:FOR EQ=0 TO 15:READ S(N,EQ):NEXT:NEXT:AU=24
210 P(0)=320:P(1)=P(0)+5:P(2)=P(1)+6:P(3)=P(2)+5:P(4)=P(3)+6:P(5)=P(4)+5
220 GOSUB 110
230 ' get time from cmos data
240 HH=VAL(MID$(TIME$,1,2)):M=VAL(MID$(TIME$,4,2)):SS=VAL(MID$(TIME$,7,2))
250 CLS:LOCATE 23,11:PRINT"<F1> to exit"
260 Z=P(0)+L+9:GOSUB 60:PRINT"#":Z=P(0)+L+20:GOSUB 60:PRINT"#"
270 Z=P(0)+(L*4)+9:GOSUB 60:PRINT"#":Z=P(0)+(L*4)+20:GOSUB 60:PRINT"#"
280 N=HH\10:PN=0:GOSUB 50:N=HH-N*10:GOSUB 40 ' hours
290 N=M\10:GOSUB 40:N=M-N*10:GOSUB 40        ' minutes
300 N=SS\10:GOSUB 40:N=SS-N*10:GOSUB 40      ' seconds
310 ' digital clock action
320 SM=SS\10:SL=SS-10*SM
330 IF SS=59 THEN PN=5:N=SL:GOSUB 80:PN=4:SN=3:GOSUB 90:GOTO 360
340 IF SL=9  THEN PN=5:N=SL:GOSUB 80:PN=4:N=SM:GOSUB 80:GOTO 360
350 PN=5:N=SL:GOSUB 80
360 SS=SS+1:IF SS=60 THEN SS=0 ELSE 320
370 MM=M\10:ML=M-10*MM
380 IF M=59 THEN PN=3:N=ML:GOSUB 80:PN=2:SN=3:GOSUB 90:GOTO 410
390 IF ML=9 THEN PN=3:N=ML:GOSUB 80:PN=2:N=MM:GOSUB 80:GOTO 410
400 PN=3:N=ML:GOSUB 80
410 M=M+1:IF M=60 THEN M=0 ELSE 320
420 HM=HH\10:HL=HH-10*INT(HH/10)
430 IF HH=AU-1 THEN 440
440 SN=2+2*(AU=12):PN=1:GOSUB 90
450 SN=-(AU=24):PN=0:GOSUB 90:GOTO 480
460 IF HL=9 THEN PN=1:N=HL:GOSUB 80:PN=0:N=HM:GOSUB 80:GOTO 480
470 PN=1:N=HL:GOSUB 80
480 HH=HH+1:IF HH=24 THEN HH=0:GOTO 320 ELSE 320
490 ' display at start up
500 PN=PN+1
510 FOR Y=0 TO 5:D$=""
520  FOR X=0 TO 3
530   BN=Y*4+X:IF B(N,BN)=1 THEN D$=D$+CHR$(C) ELSE D$=D$+" "
540  NEXT:Z=P(PN)+Y*L:GOSUB 60:PRINT D$
550 NEXT:RETURN
560 ' print@ to locate converter
570 D=INT(Z/L)+1:E=(D-1)*L:E=(Z-E)+1:LOCATE D,E:RETURN
580 ' delay 1/9 seconds
590 DELAY=1/9:START=TIMER:WHILE TIMER<START+DELAY:WEND:RETURN
600 ' change display subroutines
610 FOR K=0 TO 14 STEP 2
620  Z=P(PN)+L*(T(N,K)\4)+T(N,K) MOD 4:GOSUB 60:PRINT " ";
630  Z=P(PN)+L*(T(N,K+1)\4)+T(N,K+1) MOD 4:GOSUB 60:PRINT CHR$(C);:GOSUB 70
640 NEXT:RETURN
650 ' change display 2
660 FOR K=0 TO 14 STEP 2
670  Z=P(PN)+L*(S(SN,K)\4)+S(SN,K) MOD 4:GOSUB 60:PRINT " ";
680  Z=P(PN)+L*(S(SN,K+1)\4)+S(SN,K+1) MOD 4:GOSUB 60:PRINT CHR$(C);:GOSUB 70
690 NEXT:RETURN
700 ' initialize F1
710 ON KEY (1) GOSUB 730:KEY (1) ON
720 RETURN
730 CLS:SCREEN 2:SCREEN 0:END:RETURN
740 ' get key
750 LSET Q=MKI$(0)
760 WHILE CVI(Q)=0:MID$(Q,1)=INKEY$:WEND:RETURN
770 ' numbers in 12 circles at startup
780 DATA 1,2,4,7,8,11,12,15,16,19,21,22                  : ' 0
790 DATA 2,5,6,8,9,10,13,14,17,18,21,22                  : ' 1
800 DATA 1,2,4,7,11,13,14,16,20,21,22,23                 : ' 2
810 DATA 0,1,2,3,4,7,10,15,16,19,21,22                   : ' 3
820 DATA 0,2,4,6,8,10,12,13,14,15,18,22                  : ' 4
830 DATA 0,1,2,4,8,9,10,15,16,19,21,22                   : ' 5
840 DATA 1,2,4,8,9,10,12,15,16,19,21,22                  : ' 6
850 DATA 0,1,2,3,7,10,13,14,17,18,21,22                  : ' 7
860 DATA 1,2,4,7,9,10,12,15,16,19,21,22                  : ' 8
870 DATA 1,2,4,7,8,11,13,14,15,19,21,22                  : ' 9
880 ' change n to n+1
890 DATA 1,5,4,9,7,6,11,10,12,13,15,14,16,17,19,18       : ' 0 --> 1
900 DATA 5,1,8,4,6,7,10,11,13,16,9,13,17,20,18,23        : ' 1 --> 2
910 DATA 4,0,7,3,11,7,13,10,14,15,23,19,16,4,20,16       : ' 2 --> 3
920 DATA 21,13,16,12,4,8,1,4,3,6,19,18,10,14,7,10        : ' 3 --> 4
930 DATA 8,9,12,8,13,16,18,21,15,19,14,15,2,1,6,2        : ' 4 --> 5
940 DATA 10,14,14,13,13,12,9,10,8,9,4,8,1,4,0,1          : ' 5 --> 6
950 DATA 4,0,16,17,19,18,12,13,15,14,10,7,9,3,8,10       : ' 6 --> 7
960 DATA 0,4,10,9,7,10,3,7,13,12,14,15,17,16,18,19       : ' 7 --> 8
970 DATA 9,13,10,14,12,8,8,9,9,10,10,11,16,12,12,8       : ' 8 --> 9
980 DATA 13,17,14,18,21,16,22,21,16,12,21,16,17,21,18,22 : ' 9 --> 0
990 ' special changes
1000 DATA 5,1,9,4,6,7,10,11,13,12,14,15,17,16,18,19       : ' 1 --> 0
1010 DATA 16,12,12,8,13,12,20,16,22,18,18,19,14,15,23,22  : ' 2 --> 0
1020 DATA 4,8,8,12,0,4,4,8,10,5,5,4,7,11,3,7              : ' 3 --> 0
1030 DATA 15,11,11,7,10,15,9,10,10,11,8,12,4,8,0,4        : ' 5 --> 0
